package demo;

import bean.SecurityRecord;
import com.jfinal.config.*;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
import com.jfinal.plugin.druid.DruidPlugin;

public class DemoConfig extends JFinalConfig {
    public void configConstant(Constants me) {
        me.setDevMode(true);
    }

    public void configRoute(Routes me) {
        me.add("/", HelloController.class);
    }

    public void configPlugin(Plugins me) {
//        String host = PropKit.get("jdbc.host", "jdbc:postgresql://localhost:5432/child_spring");
        String url = PropKit.get("jdbc.host", "localhost");
        String user = PropKit.get("jdbc.username", "root");
        String pass = PropKit.get("jdbc.password", "postgresql");
        DruidPlugin dp = new DruidPlugin(url, user, pass);
        ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
        arp.setDialect(new PostgreSqlDialect());
        me.add(arp);

        dp.start();
        arp.start();

//        arp.addMapping("clock_record", SecurityRecord.class);
    }

    public void configInterceptor(Interceptors me) {
    }

    public void configHandler(Handlers me) {
    }
}